import axios from './axios.js';
const HTTP_PREFIX = 'api/planning/api/v1/workspaces/waylines'  //这里多加了一个api是因为用了脚手架的代理，详细见vue.cofig.js


/**
 * 航线规划
 */
// 添加巡检任务
 export const planAdd = async function (body){
     const url = `${HTTP_PREFIX}/wayline/add`
    console.log("发送航线",body)
     const result = await axios.post(url, body)
    return result.data
}

// 添加kml航线任务
export const kmlAdd = async function (body) {
    const url = `${HTTP_PREFIX}/kmz/upload`
    const result = await axios.post(url, body)
    return result.data
}

// 逐点巡检检测航点有效性
 export const checkPointValid = async function (body){
    const url = `${HTTP_PREFIX}/planning/check_point_valid`
    const result = await axios.post(url,body)
    return result.data
  }
// 批量检测航点有效性
  export const checkPointsValid = async function (body){
    const url = `${HTTP_PREFIX}/planning/check_points_valid`
    const result = await axios.post(url,body)
    return result.data
  }
// 检测航线有效性
  export const checkLineValid = async function (body){
    const url = `${HTTP_PREFIX}/planning/check_line_valid`
    const result = await axios.post(url,body)
    return result.data
  }
// 删除航线规划任务
  export const deletePlan = async function (id){
    const url = `${HTTP_PREFIX}/delete/${id}`
    const result = await axios.delete(url)
    return result.data
  }
// 更新航线规划任务
  export const updatePlan = async function (body){
    const url = `${HTTP_PREFIX}/wayline/add`
    const result = await axios.post(url,body)
    return result.data
  }
// 获取航线列表demo
  // export const searchPlan = async function (){
  //   const url = '/demo/example'
  //   const result = await axios.get(url)
  //   return result.data
  // }
// 旧版获取航线列表
  /*
  export const searchPlan = async function (){
    const url = `${HTTP_PREFIX}/search/?unit=current`
    const result = await axios.get(url)
    return result.data
}
*/

export const searchPlan = async function () {
    const url = `${HTTP_PREFIX}/wayline/get`
    const result = await axios.get(url)
    return result.data
}

  export const searchPlanById = async function (id){
    const url = `${HTTP_PREFIX}/wayline/get?wayline_id=${id}`
      const result = await axios.get(url)
    return result.data
}